package com.bdqn.utils;

import java.util.List;

public class PageSupport <T>{
    private int pageSize = 1; // 固定的值

    private int currentPageNo = 1;
    private int totalPageCount;
    private int totalCount;
    private List<T> data;

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return currentPageNo;
    }

    public void setPageNo(int currentPageNo) {

        this.currentPageNo = currentPageNo <= 0 ? 1 : (currentPageNo > totalPageCount ? totalPageCount : currentPageNo);
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    private void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public int getTotalCount() {
        return totalCount;
    }


    public void setTotalCount(int totalCount) {

        this.totalCount = totalCount < 0 ? 0 : totalCount; // 101

        this.totalPageCount = this.totalCount % this.pageSize == 0 ? (this.totalCount / this.pageSize) : (this.totalCount / this.pageSize + 1); // 11
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public void setCurrentPageNo(Integer currentPageNo) {
        this.currentPageNo = currentPageNo;
    }
}
